<script>
	
	let prd = {
		price: 10,
		count: 2
	}
	// prd 被代理对象
	// proxyPrd是一个代理对象, 使用代理对象才触发set，get方法
	const proxyPrd = new Proxy(prd, {
		set(target, key, value, receiver) {
			console.log('setter', target, key, value, receiver)
			target[key] = value
			effect()
			return true
		},
		get(target, key, receiver) {
			console.log('getter', target, key, receiver)
			return target[key]
		}
	})


	let total = 0;
	let effect = () => {
		total = proxyPrd.price * proxyPrd.count;
	}
	effect();
	console.log(total);
</script>